/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	win7 
 * 
 * <p>描   述  :   PolicyCriterionServiceImpl.java for com.pengtu.gsj.service.impl.jsbz    </p>
 * 
 * <p>最后修改 : $: 2017年8月9日-下午3:36:16 v 1.0.0	 win7   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.jsbz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.jsbz.PolicyCriterionDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.jsbz.PolicyCriterion;
import com.pengtu.gsj.service.jsbz.PolicyCriterionService;
import com.pengtu.gsj.service.system.SystemManageService;

/**
 * 
 * PolicyCriterionServiceImpl
 * 
 * 2017年8月9日 下午3:36:16
 * 
 * @version 1.0.0
 * 
 */
@Service
@Transactional
public class PolicyCriterionServiceImpl implements PolicyCriterionService {
	@Autowired
	private PolicyCriterionDao policyCriterionDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	
	
	@Override
	public void savePolicyCriterion(PolicyCriterion policyCriterion){
		policyCriterionDao.save(policyCriterion);
	}
	
	@Override
	public Page<PolicyCriterion> findPolicyCriterion(Page<PolicyCriterion> page, final QueryFilter queryFilter){
		return policyCriterionDao.findPage(page, queryFilter);
	}
	
	@Override
	public PolicyCriterion getPolicyCriterionById(String id){
		return policyCriterionDao.get(id);
	}
	
	@Override
	public void  delatePolicyCriterion(PolicyCriterion policyCriterion){
		if(policyCriterion.getAttachments() != null){
			for(Attachment attachment : policyCriterion.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		policyCriterionDao.delete(policyCriterion);
	}
	
}
